<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //改变 promise 状态和指定回调函数谁先谁后?
        //先改变状态, 后指定回调
        // let p = new Promise((resolve, reject) => {
        //     resolve('ok');
        // });

        //先指定回调, 后改变状态
        let p = new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve('OK');
            }, 1000);
        })

        p.then(value => {
            console.log(value);
        }, reason => {
            console.log(reason);
        });


    </script>
</body>

</html>